package com.cloud.core.demo

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Wc_main {

  def main(args: Array[String]): Unit = {
    val sc = new SparkContext()
    val lang = "python"
    sc.textFile("hdfs://master:9000/wcinput/" + lang + "/")
      .flatMap(_.split(" "))
      .map((_, 1))
      .reduceByKey(_ + _)
      .sortBy(_._2, false)
      .saveAsTextFile("hdfs://master:9000/wordcount/20221123/" + lang + "/")
  }

}
